﻿using System;
using System.Windows.Forms;

namespace Module_Debug
{
    public partial class Raw_R_Measure_Frm : Form
    {
        public Raw_R_Measure_Frm()
        {
            InitializeComponent();
        }
        private void Raw_R_Measure_Frm_Load(object sender, EventArgs e)
        {
            //DemuraAutoMeasure RCM = new DemuraAutoMeasure();
            for (int j = 0; j < DemuraAutoMeasure.GrayRGBSelectAll.Length; j++)
            {
                double a = Convert.ToDouble(DemuraAutoMeasure.Daw_Red_Y_Axie[j]);
                chart_RGam_Curve.Series[0].Points.AddXY(DemuraAutoMeasure.GrayRGBSelectAll[j], Math.Round(DemuraAutoMeasure.Daw_Red_Y_Axie[j], 4));  //GrayRGBSelectAll_Value[j]
            }
        }
        private void Draw_ULValue()
        {
            for (int j = 0; j < DemuraAutoMeasure.GrayRGBSelectAll.Length; j++)
            {
                chart_RGam_Curve.Series[2].Points.AddXY(DemuraAutoMeasure.GrayRGBSelectAll[j], Math.Round(Math.Pow(Convert.ToDouble(DemuraAutoMeasure.GrayRGBSelectAll[j]) / 255, Convert.ToDouble(txt_RGam_ULValue.Text)) * Convert.ToDouble(DemuraAutoMeasure.Daw_Red_Y_Axie[0]), 4));//Gamma2.1
            }
        }
        private void Draw_DLValue()
        {
            for (int j = 0; j < DemuraAutoMeasure.GrayRGBSelectAll.Length; j++)
            {
                chart_RGam_Curve.Series[3].Points.AddXY(DemuraAutoMeasure.GrayRGBSelectAll[j], Math.Round(Math.Pow(Convert.ToDouble(DemuraAutoMeasure.GrayRGBSelectAll[j]) / 255, Convert.ToDouble(txt_RGam_DLValue.Text)) * Convert.ToDouble(DemuraAutoMeasure.Daw_Red_Y_Axie[0]), 4));//Gamma2.2
            }
        }
        private void Draw_Custum_Value()
        {
            for (int j = 0; j < DemuraAutoMeasure.GrayRGBSelectAll.Length; j++)
            {
                chart_RGam_Curve.Series[1].Points.AddXY(DemuraAutoMeasure.GrayRGBSelectAll[j], Math.Round(Math.Pow(Convert.ToDouble(DemuraAutoMeasure.GrayRGBSelectAll[j]) / 255, Convert.ToDouble(txt_Custum_Value.Text)) * Convert.ToDouble(DemuraAutoMeasure.Daw_Red_Y_Axie[0]), 4));//Gamma2.0
            }
        }

        private void txt_RGam_ULValue_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
                chart_RGam_Curve.Series[2].Points.Clear();
            Draw_ULValue();
        }

        private void txt_RGam_DLValue_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
                chart_RGam_Curve.Series[3].Points.Clear();
            Draw_DLValue();
        }

        private void txt_Custum_Value_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
                chart_RGam_Curve.Series[1].Points.Clear();
            Draw_Custum_Value();
        }
    }
}
